<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库：https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库：https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\service\NodeService;
use library\Controller;
use library\tools\Data;
use think\Console;
use think\Db;
use think\Request;
use think\exception\HttpResponseException;

/**
 * 充值活动管理
 * Class Index
 * @package app\admin\controller
 */
class ChargeActive extends Controller
{
    /**
     * 绑定数据表
     * @var string
     */
    protected $table = 'ChargeActive';
   
    /**
     * 充值活动列表
     * @auth true
      * @menu true
     */
    public function index()
    {

        $this->title = ' 充值活动列表';
        $id=$this->request->param('id', 0);
        $query = $this->_query($this->table)
                ->like('name')
                ->equal('status');
        $query->order('id desc')->page();
    }

   
    /**
     * 添加活动
     * @auth true
     */
    public function activeAdd()
    {   

        $this->title = '添加广告';   
        $this->_form($this->table, 'active_add');
       
    }
    protected function _form_filter(&$data)
    {

        if ($this->request->isPost()) {

            $data['start_time']=strtotime($data['start_time']);
            $data['end_time']=strtotime($data['end_time']);

        }
        
    }
    /**
     * 表单结果处理
     * @param boolean $result
     */
    protected function _form_result($result)
    {
        if ($result && $this->request->isPost()) {
            $this->success('操作成功！','javascript:history.back()');
        }
    }
    /**
     * 编辑活动
     * @auth true
     */
    public function edit(){

        $this->title="编辑活动";
        $this->_form($this->table, 'active_add');
    }

    /**
     * 禁用活动
     * @auth true
     */
     public function forbid()
    {
        $this->_save($this->table, ['status' => '0']);
    }

    /**
     * 启用活动
     * @auth true
     */
    public function resume()
    {
        $this->_save($this->table, ['status' => '1']);
    }

    

}
